# -*- coding: utf-8 -*-
"""
Created on Tue Oct 26 22:03:04 2021

@author: think
"""

from DigitalEnvelope import digitalEnvelope



message = input("Please input your message: ")
print()

#DES公钥定义（pyDES库必须要求密钥长度是8（64位））
key = "hashcode"

envelope = digitalEnvelope()

#Sender和Receiver的公钥和私钥定义
#因为rsa库的设定就是只有pub_key类（生成密钥函数返回元组的后者）可以解密，所以Receiver的公私钥必须反过来定义
#默认为512位
privkeyS, pubkeyS = envelope.generateRSAKeys()
pubkeyR, privkeyR = envelope.generateRSAKeys()

#发送方加密
crypto = envelope.getEnvelope(message, privkeyS, pubkeyR, key)
print("The encoded message is: ")
print(crypto)#输出加密后的信息

#接收方解密
getmsg = envelope.removeEnvelope(crypto, pubkeyS, privkeyR)
print()
print("The original message is: ")
print(getmsg.decode("utf-8"))


#中途篡改了之后连RSA解密这一关都过不去……就不写了